<?php

abstract class @@serviceName@@ {
    function serviceRequest($implementation) {
        $rawData = file_get_contents('php://input');
        $postData = json_decode($rawData, true);
        
        $method = $postData['method'];
        $params = $postData['params'];
        
        $helper = new JsonizerHelper();
        $helper->jsonObjects = $params['references'];
        $params = $params['value'];
        
        $argv = array();
        
        $result = null;
        $error = null;
        
        try {
            @@methodCalls@@
            } else {
                throw new Exception("Unknown method [$method]");
            }
        } catch (Exception $e) {
            $error = $e->getMessage();
        }
        
        if ($error !== null) {
            $response = array('result' => null, 'error' => $error);
        } else {
            $response = array('result' => $result, 'error' => null);
        }
        
        return json_encode($response);
    }
    
@@methodDeclarations@@
}

?>
